package com.x_memteor.base_master.bean.type_adapter;

import android.text.TextUtils;

import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.x_memteor.base_master.bean.request.NewHeartBody;
import com.x_memteor.base_master.bean.request.TokenBody;

import java.io.IOException;

/**
 * @author: X_Meteor
 * @description: 类描述
 * @version: V_1.0.0
 * @date: 2018/3/12 0012 下午 5:03
 * @company:
 * @email: lx802315@163.com
 */
public class NewHeartTypeAdapter extends TypeAdapter<NewHeartBody> {

    @Override
    public void write(JsonWriter out, NewHeartBody value) throws IOException {
        out.beginObject();
        //按自定义顺序输出字段信息
        if (!TextUtils.isEmpty(value.getCode())) {
            out.name("code").value(value.getCode());
        }
        out.name("time").value(value.getTime());
        if (!TextUtils.isEmpty(value.getMac())) {
            out.name("mac").value(value.getMac());
        }
        out.name("version_id").value(value.getVersion_id());
        out.endObject();
    }

    @Override
    public NewHeartBody read(JsonReader in) throws IOException {
        return null;
    }

}
